<template>
  <div>
    <el-row>
      <el-col :span="24" class="addRole">
        <!-- 查询 -->
        <el-popover placement="bottom-start" width="1000" style="margin-right:10px;" trigger="click">
          <el-form :inline="true" :model="search">
              <el-form-item label="图纸编号" >
                  <el-input v-model="search.drawCode"></el-input>
              </el-form-item>
              <el-form-item label="生产令号" >
                  <el-input v-model="search.makeNo"></el-input>
              </el-form-item>
              <el-form-item label="任务流水号" >
                  <el-input v-model="search.taskSerialNo"></el-input>
              </el-form-item>
              <!-- <el-form-item label="自定义编码" >
                  <el-input v-model="search.code"></el-input>
              </el-form-item> -->
              <el-form-item label="任务单号" >
                  <el-input v-model="search.taskNo"></el-input>
              </el-form-item>
              <el-form-item label="客户" >
                  <el-input v-model="search.customer"></el-input>
              </el-form-item>
              <el-form-item label="29所编码" >
                  <el-input v-model="search.code29"></el-input>
              </el-form-item>                     
              <el-form-item label="排程时间" >
                 <el-date-picker
                    v-model="search.startDate"
                    type="date" style="margin-top:-3px"
                    placeholder="选择日期">
                  </el-date-picker>
              </el-form-item>-                     
              <el-form-item label="" >
                 <el-date-picker
                    v-model="search.endDate"
                    type="date" style="margin-top:-3px"
                    placeholder="选择日期">
                  </el-date-picker>              </el-form-item>                     
              <el-form-item label="状态" >
                <el-select v-model="search.processDetailState" placeholder="请选择">
                  <el-option v-if="isSxpc==1" label="待排程筛选" value="1"></el-option>
                  <el-option v-if="isSxpc==1" label="待排程" value="2"></el-option>
                  <el-option v-if="isPtxf==1" label="待生产准备/待下发任务" value="3"></el-option>
                  <el-option label="待签收" value="4"></el-option>
                  <el-option label="待开工" value="5"></el-option>
                  <el-option label="已开工" value="6"></el-option>
                  <el-option label="完工送检" value="7"></el-option>
                </el-select>
              </el-form-item>            
              <el-button type="primary" @click="searchBtn">确认</el-button>
              <el-button type="primary" @click="reSearchBtn">重置</el-button>
          </el-form>
          <el-button slot="reference" type="primary" icon="el-icon-search">查询</el-button>
        </el-popover>
          <el-button type="primary" @click="choosePc">排程筛选</el-button>
      </el-col>
    </el-row>
    <!-- 29所列表 -->
    <productionPlanList ref="tableList29" :postData="postData" @selectedData="getSelectedData">
      <template v-slot:default="scope" >
        <el-button v-if="scope.row.processState==='3' && scope.row.processStateDesc === '待下发'" @click="planTask('3',scope.row)" type="text" size="small">任务下发</el-button>
        <el-button v-if="scope.row.processState==='4'" @click="planTask('4',scope.row)" type="text" size="small">签收</el-button>
        <el-button v-if="scope.row.processState==='5'" @click="planTask('5',scope.row)" type="text" size="small">开工</el-button>
        <el-button v-if="scope.row.processState==='6'" @click="planTask('6',scope.row)" type="text" size="small">完工</el-button>
        <el-button @click="showDialog('update',scope.row)" type="text" size="small">详情</el-button>
        <el-button  v-if="scope.row.couldMpWx == 1" @click="showDialog('imsertWx',scope.row)" type="text" size="small">毛坯外协</el-button>
      </template>
    </productionPlanList>
    <!-- 计划任务详情 -->
    <el-dialog class="bodyNopaddingTop" :title="dialog.title" :visible.sync="dialog.isShow"  v-dialogDrag width="1100px" @opened="dialogOpened" @closed="dialogClosed">
      <el-tabs v-model="dialog.activeName" @tab-click="dialogHandleClick">
        <el-tab-pane label="详情" name="1">
            <taskDetail29 :detailObj="dialog.formData" :isChange="isChange" :type="dialog.type" :editDisalbe="true"></taskDetail29>
        </el-tab-pane>
        <el-tab-pane label="生产工序记录" name="7" v-if="dialog.title==='计划详情'">
          <productionRecordList :tid="dialog.formData.id" :currentName="postData.name" ref="productionRecordListRef"></productionRecordList>
        </el-tab-pane>
        <el-tab-pane label="工艺编制" name="6" v-if="dialog.title==='计划详情'">
          <processPlanList ref="processPlanListRef" :drawCode="dialog.drawCode" :formData="dialog.formData">
            <template v-slot:default="scope" >
              <el-button @click="showProgramDialog(scope.row)" type="text" size="small">详情</el-button>
            </template>
          </processPlanList>
        </el-tab-pane>

        <el-tab-pane label="29所工艺" name="2" v-if="dialog.title==='计划详情'">
          <processPlanList29 :data="dialog.formData" ref="processPlanList29Ref">
              <template v-slot:default="scope">
                <el-button @click="showDialog1('update',scope.row)" type="text" size="small">详情</el-button>
              </template>
          </processPlanList29>
        </el-tab-pane>
        <el-tab-pane label="图纸上传" name="3" v-if="dialog.title==='计划详情'">
          <uploadList :upLoadType="1" :drawNo="dialog.drawCode"  ref="drawing"></uploadList>
        </el-tab-pane>
        <el-tab-pane label="工艺上传" name="4" v-if="dialog.title==='计划详情'">
           <uploadList :upLoadType="2" :drawNo="dialog.drawCode"  ref="technology"></uploadList>
        </el-tab-pane>
        <el-tab-pane label="图形文件上传" name="5" v-if="dialog.title==='计划详情'">
           <uploadList :upLoadType="3" :drawNo="dialog.drawCode"  ref="graphicsFile"></uploadList>
        </el-tab-pane>
      </el-tabs>
    </el-dialog>
    <!-- 新增编辑29所计划任务详情 -->
    <el-dialog class="bodyNopaddingTop" :title="dialog1.title" :visible.sync="dialog1.isShow" v-dialogDrag>
       <processPlanDetail29 :formData="dialog1.formData" :type="dialog1.type" :tid="dialog.formData.tid" :disabled='true'></processPlanDetail29>
    </el-dialog>
    <!-- 编程列表 -->
     <el-dialog class="bodyNopaddingTop" :title="programDialog.title" :visible.sync="programDialog.isShow" v-dialogDrag @opened="openedProgramDialog">
       <programList :programObj ="programDialog.programObj" ref="programDetail" status="watch"></programList>
    </el-dialog>
    <!-- 新增页面 -->
     <el-dialog class="bodyNopaddingTop" :title="wxDialog.title" :visible.sync="wxDialog.isShow" v-dialogDrag >
        <el-form :model="detailObj"  ref="ruleForm" label-width="140px" class="demo-ruleForm" :inline="true">
                <!-- <el-form-item label="任务单号" prop="taskNo">
                  <el-input v-model="detailObj.planTaskTotal.taskNo" class="width220" disabled></el-input>
                </el-form-item>
                <el-form-item label="任务流水号" prop="taskSerialNo" v-if="type!=='insert'">
                  <el-input v-model="detailObj.planTaskTotal.taskSerialNo" class="width220" disabled></el-input>
                </el-form-item>
                <el-form-item label="生产令号" prop="makeNo">
                  <el-input v-model="detailObj.planTaskTotal.makeNo" class="width220" disabled></el-input>
                </el-form-item>
                <el-form-item label="图纸序号" prop="drawNo">
                  <el-input v-model="detailObj.planTaskTotal.drawNo" class="width220" :disabled="editDisalbe"></el-input>
                </el-form-item>
                <el-form-item label="29所编码" prop="code"  v-if="type!=='insert'">
                  <el-input v-model="detailObj.planTaskTotal.code29" class="width220" disabled></el-input>
                </el-form-item>

                <el-form-item label="外包计划完成时间" prop="wbPlanFinsihDate">
                  <el-date-picker v-model="detailObj.planTaskTotal.wbPlanFinsihDate" type="datetime"  placeholder="外包完成时间" class="width220 noMargin" :disabled="editDisalbe"></el-date-picker>
                </el-form-item>

                <el-form-item label="件数" prop="nums">
                  <el-input v-model="detailObj.planTaskTotal.nums" class="width220" :disabled="editDisalbe" ></el-input>
                </el-form-item>
                <el-form-item label="图纸编号" prop="drawCode">
                  <el-input v-model="detailObj.planTaskTotal.drawCode" class="width220" disabled></el-input>
                </el-form-item>
                <el-form-item label="图纸名称" prop="drawName">
                  <el-input v-model="detailObj.planTaskTotal.drawName" class="width220" disabled ></el-input>
                </el-form-item>
                <el-form-item label="项目图纸张数" prop="drawNums">
                  <el-input v-model="detailObj.planTaskTotal.nums" class="width220" :disabled="editDisalbe" ></el-input>
                </el-form-item> -->

                <el-form-item label="外协时间" prop="remark" >
                  <el-date-picker v-model="detailObj.wxTime" type="datetime"  placeholder="外协时间" class="width220 noMargin" ></el-date-picker>

                </el-form-item>

                <el-form-item label="外协人员" prop="remark">
                    <el-select v-model="detailObj.wxUser" filterable clearable placeholder="请选择"   >
                      <el-option
                        v-for="item in workerList"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id">
                      </el-option>
                    </el-select> 
                </el-form-item>

                
                <el-form-item label="计划交货日期" prop="remark" >
                  <el-date-picker v-model="detailObj.planDeliveryDate" type="date"    placeholder="外协时间" class="width220 noMargin" ></el-date-picker>
                </el-form-item>

                
                <el-form-item label="实际交货日期" prop="remark">
                  <el-date-picker v-model="detailObj.realDeliveryDate" type="date"  placeholder="外协时间" class="width220 noMargin"></el-date-picker>
                </el-form-item>

                
                <el-form-item label="外协厂家" prop="remark" >
                  <el-input v-model="detailObj.wxProducer"  class="width220"  ></el-input>
                </el-form-item>

                
                <el-form-item label="合格数量" prop="remark" >
                  <el-input v-model="detailObj.qualifiedNums"  class="width220"  ></el-input>
                </el-form-item>

                
                <el-form-item label="不合格数量" prop="unqualifiedNums">
                  <el-input v-model="detailObj.unqualifiedNums"  class="width220"  ></el-input>
                </el-form-item>


                
                <el-form-item label="创建时间" prop="unqualifiedNums" >
                  <el-date-picker v-model="detailObj.createTime" type="datetime"  placeholder="外协时间" class="width220 noMargin"  ></el-date-picker>
                </el-form-item>


                
                <el-form-item label="外协创建人" prop="unqualifiedNums" >
                  <el-input v-model="detailObj.createUserName"  class="width220"  ></el-input>
                </el-form-item>



                <el-form-item label="备注" prop="remark" >
                  <el-input v-model="detailObj.remark"  class="width220" type="textarea"  ></el-input>
                </el-form-item>
                <!-- <el-form-item label="导入人" prop="importerName" v-if="type==='update'">
                  <el-input v-model="detailObj.importerName" disabled class="width220" ></el-input>
                </el-form-item>
                <el-form-item label="导入时间" prop="importDate" v-if="type==='update'">
                  <el-input v-model="detailObj.importDate" disabled class="width220" ></el-input>
                </el-form-item> -->
                <el-form-item  class="form-item-block text-center" style="margin-top:15px;" >
                  <el-button type="primary" @click="onSubmit()">确定</el-button>
                </el-form-item>
        </el-form>
    </el-dialog>
    <!-- 状态操作 -->
     <el-dialog class="bodyNopaddingTop" :title="statusDialog.title" :visible.sync="statusDialog.isShow" v-dialogDrag >
      <span v-if="statusDialog.type==='3'" >                     
        <h1 style="color: #FFFFFF;background-color: #3ac1c4;margin-bottom:15px;padding:5px 0px 5px 15px; border-radius:3px;">员工清单</h1>
        <div style="width:90%;height:40%;border:1px solid gray; margin:0 auto; padding:5px 5px 5px 5px;">
          <el-checkbox-group v-model="operatorList">
              <span v-for="(item,i) in operatorData">
                <el-checkbox :label="item.id">{{item.name}}</el-checkbox>
                 &nbsp;&nbsp;
              </span>
          </el-checkbox-group>
        </div> 
        <el-button type="primary" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" @click="setOperator" >派工</el-button>
        <el-button type="primary" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" @click="clearSetOperatorPopoverHander" >清空</el-button>
        <el-button type="danger" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" @click="closeSetOperatorPopver" >关闭</el-button>   
      </span>   
      <span v-if="statusDialog.type==='6'" >                     
        <h1 style="color: #FFFFFF;background-color: #3ac1c4;margin-bottom:15px;padding:5px 0px 5px 15px; border-radius:3px;">工作记录</h1>
        <el-form :model="workRecord"  ref="ruleForm" label-width="140px" class="demo-ruleForm" :inline="true">
            <el-form-item label="工作内容:" prop="remark" > 
              <el-input type="textarea" style="width:600px;"></el-input>  
              <el-button type="primary" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" @click="setOperator" >提交记录</el-button>
            </el-form-item>
            <br>
            <br>
            <el-form-item label="首检:" prop="remark" > 
              <el-input type="textarea" style="width:600px;"></el-input>
              <el-button type="primary" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" @click="setOperator" >提交首检</el-button>
            </el-form-item> 
            <br>
            <br>           
            <br>
            <el-form-item label="过程检:" prop="remark" > 
              <el-input type="textarea" style="width:600px;"></el-input>
              <el-button type="primary" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" @click="setOperator" >提交过程检</el-button>
            </el-form-item>
            <br>           
            <br>
            <el-form-item label="返工:" prop="remark" > 
              <el-input type="textarea" style="width:600px;"></el-input>
              <el-button type="primary" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" @click="setOperator" >提交返工</el-button>
            </el-form-item> 
            <br>           
            <br>
            <el-form-item label="报废:" prop="remark" > 
              <el-input type="textarea" style="width:600px;"></el-input>
              <el-button type="primary" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" @click="setOperator" >提交报废</el-button>
            </el-form-item>
            <br>           
            <br>
            <el-form-item label="成品:" prop="remark" > 
              <el-input type="textarea" style="width:600px;"></el-input>
              <el-button type="primary" size="small" style="margin-bottom:0px; float:right;margin:10px 5px 10px 5px;" @click="setOperator" >提交成品</el-button>
            </el-form-item>
        </el-form>
      </span>   
        <!-- <el-form :model="detailObj"  ref="ruleForm" label-width="140px" class="demo-ruleForm" :inline="true">
                <el-form-item label="外协时间" prop="remark" >
                  <el-date-picker v-model="detailObj.wxTime" type="datetime"  placeholder="外协时间" class="width220 noMargin" ></el-date-picker>
                </el-form-item>
                <el-form-item label="外协人员" prop="remark">
                    <el-select v-model="detailObj.wxUser" filterable clearable placeholder="请选择"   >
                      <el-option
                        v-for="item in workerList"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id">
                      </el-option>
                    </el-select> 
                </el-form-item>
                <el-form-item label="计划交货日期" prop="remark" >
                  <el-date-picker v-model="detailObj.planDeliveryDate" type="date"    placeholder="外协时间" class="width220 noMargin" ></el-date-picker>
                </el-form-item>

                <el-form-item label="实际交货日期" prop="remark">
                  <el-date-picker v-model="detailObj.realDeliveryDate" type="date"  placeholder="外协时间" class="width220 noMargin"></el-date-picker>
                </el-form-item>

                <el-form-item label="外协厂家" prop="remark" >
                  <el-input v-model="detailObj.wxProducer"  class="width220"  ></el-input>
                </el-form-item>

                
                <el-form-item label="合格数量" prop="remark" >
                  <el-input v-model="detailObj.qualifiedNums"  class="width220"  ></el-input>
                </el-form-item>

                
                <el-form-item label="不合格数量" prop="unqualifiedNums">
                  <el-input v-model="detailObj.unqualifiedNums"  class="width220"  ></el-input>
                </el-form-item>
  
                <el-form-item label="创建时间" prop="unqualifiedNums" >
                  <el-date-picker v-model="detailObj.createTime" type="datetime"  placeholder="外协时间" class="width220 noMargin"  ></el-date-picker>
                </el-form-item>

                <el-form-item label="外协创建人" prop="unqualifiedNums" >
                  <el-input v-model="detailObj.createUserName"  class="width220"  ></el-input>
                </el-form-item>

                <el-form-item label="备注" prop="remark" >
                  <el-input v-model="detailObj.remark"  class="width220" type="textarea"  ></el-input>
                </el-form-item>

                <el-form-item  class="form-item-block text-center" style="margin-top:15px;" >
                  <el-button type="primary" @click="onSubmit()">确定</el-button>
                </el-form-item>
        </el-form> -->
    </el-dialog>
  </div>
</template>
<script>
import planApi from 'plugins/axios/planApi.js';
import baseApi from 'plugins/axios/baseApi.js';
import materielApi from 'plugins/axios/materielApi.js';
import uploadList from 'views/components/uploadList.vue' /**1-图纸上传、2-工艺上传、3-图形文件上传 的列表组件 */
import productionPlanList from 'views/components/productionPlanList.vue' /**29所列表组件 */
import taskDetail29 from 'views/components/taskDetail29.vue' /**29所任务详情组件 */
import processPlanList29 from 'views/components/processPlanList29.vue' /**29所工序列表组件 */
import processPlanDetail29 from 'views/components/processPlanDetail29.vue' /**29所工序详情组件 */
import processPlanList from 'views/components/processPlanList.vue' /**工艺编制列表组件 */
import programList from 'views/components/programList.vue' /**编程详情组件 */
import productionRecordList from 'views/components/productionRecordList.vue' /**生产记录列表 */


export default {
  components: {
    uploadList,
    productionPlanList,
    taskDetail29,
    processPlanList29,
    processPlanDetail29,
    processPlanList,
    programList,
    productionRecordList
  },
  data(){
    return {
      workRecord:'',
      status:'0',
      isSxpc:sessionStorage.getItem('ROLE_sxpc'),//当前用户是否拥有数铣排程权限
      isPtxf:sessionStorage.getItem('ROLE_ptxf'),//当前用户是否拥有任务下发权限
      postData:{
        isUploadDraw:1,
        isMaterialArrvie:1,
        isMaterialTailor:1,
        isFinishProcess:1,
        planStatus:1,
      },
      workerList:[],//工作人员列表
      machineAllList:[],/**所有机器列表 */
      search:{
        drawCode:"",
        makeNo:"",
        code:"",
        taskNo:'',
        customer:'',
        code29:'',
        taskSerialNo:'',
        processDetailState:null,
        startDate:'',
        endDate:'',
      },
      detailObj:{
            // startWxTime:'', //外协时间（开始）
            // endWxTime:'',   //外协时间（结束）
            // wxUser:'', //外协人员
            // wxProducer:'', //外协厂家
            // startPlanDeliveryDate:'', //计划交货日期（开始）
            // endPlanDeliveryDate:'', //计划交货日期（结束）
            // startRealDeliveryDate:'', //实际交货日期（开始）
            // endRealDeliveryDate:'', //实际交货日期（结束）
            // customer:'',
            // taskNo:'', //任务单号
            // taskSerialNo:'', //流水号
            // makeNo:'', //生产令号
            // startWbPlanFinsihDate:'', //外包完成时间（开始）
            // endWbPlanFinsihDate:'', //外包完成时间（结束）
            // drawCode:'', //图纸编号
            // drawName:'', //图纸名称
            // status:this.status, //状态：待办0，已办1
      },
      dialog:{/**弹框配置 */
        title:'',
        isShow:false,
        type:'',
        formData:{},
        activeName:'2',
        otherUpDataData:{},
        tableData:[],
        drawCode:''
      },
      dialog1:{
        title:'',
        isShow:false,
        formData:{},
        rules:{}
      },
      wxDialog:{
        title:'',
        isShow:false,
        formData:{},
        rules:{}
      },
      statusDialog:{
        title:'',
        isShow:false,
        formData:{},
        rules:{}
      },
      programDialog:{/**程序列表 */
        tid:'',
        title:'',
        isShow:false,
      },
      operatorList:[],
      setOperatorPopoverShow:false,
      setOperatorId:'',
      processDetailId:'',
      operatorData:[],
      operator:{
                operator1:[],       //早班
                operator2:[],       //白班
                operator3:[],       //夜班
                operatorShift:[
                    {name:'早班',value:1},
                    {name:'白班',value:2},
                    {name:'夜班',value:3}
                ],   //操作班次
                operatorData:[],    //对应班次人员信息
                shift:1,            //所选班次 默认早班被选中
                operator:'',        //被选中的人
                remark:'',          //备注
                planResultIds:[],   //计划工艺甘特图后台数据id（批量）
                planResultId:'',    //计划工艺结果ID(单)
      },
      processDetailIds:'',
      isChange:false,
    }
  },
  mounted(){
    this.status = this.$route.query.status;
    this.nameType= this.$route.query.name;
    this.initOperator();
    this.getTablList();
    
  },
  created(){
    this.queryWorkerList();
  },
  watch: {
    $route(){
      this.status = this.$route.query.status;
      this.nameType= this.$route.query.name
      this.search.drawCode="";
      this.search.makeNo="";
      this.search.code="";
      this.initOperator();
      this.getTablList();
    }
  },
  methods:{
    clearSetOperatorPopoverHander(){
      let self = this;
      self.operatorList = [];
    },
        //任务下发
    setOperator(){
      let self = this;
      this.$confirm('是否下发任务?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
        }).then(() => {
          let param = {
                rwXfWorkers:self.operatorList.join(',')
          };
          planApi.updateRwxf(self.processDetailId,param).then(res=>{
            self.$message.success("下发成功");
            self.statusDialog.isShow = false;
          });
        }).catch(() => {
        });
    },
    updateRwqs(){
      //签收
      let self = this;
          planApi.updateRwqs(self.processDetailId).then(res=>{
            self.$message.success("签收成功");
             this.getTablList();

          });
    },
    updateRwkg(){
      //开工
      let self = this;
          planApi.updateRwkg(self.processDetailId).then(res=>{
            self.$message.success("开工成功");
            this.getTablList();
          });
    },
    updateRwwg(){
      //完工
      let self = this;
          planApi.updateRwwg(self.processDetailId).then(res=>{
            self.$message.success("完工成功");
            this.getTablList();
          });
    },
    selectProcessDetailGc(){
      let self = this;
      planApi.selectProcessDetailGc(self.processDetailId).then(res=>{

      });
    },
    choosePc(){
      //选择预排程数据
      let self = this;    
      this.$confirm('是否选择排程?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
        }).then(() => {
          if(self.processDetailIds!=null && self.processDetailIds.length>0){
              let param = {
                processDetailIds:self.processDetailIds
              };
              planApi.choosePc(param).then(res=>{
                    self.$message.success("预排成功");
                    this.getTablList();
              });
          }else{
                self.$message.warning("请选中待排程筛选数据");
          }
        }).catch(() => {
        });

    },
        //关闭操作
    closeSetOperatorPopver(){
            let self = this;
            self.statusDialog.isShow = false;
            self.clearSetOperatorPopoverHander();
    }, 
    //初始化查询排班人员信息
    initOperator(){
            let self = this;
            let deptCode = self.nameType;
            let param = '';
            /**
             *
              数铣组 SX_GROUP
              普洗组 PX_GROUP
              车工组 PC_GROUP
              钳工组 QG_GROUP
              检验组 JY_GROUP
             * 
             */
            switch(deptCode){
              case '1':param ='PX_GROUP';break;
              case '2':param ='SX_GROUP';break;
              case '3':param ='PC_GROUP';break;
              case '4':param ='PC_GROUP';break;
              case '5':param ='QG_GROUP';break;
              case '6':param ='JY_GROUP';break;
            }
            planApi.getDeptAllUsersByCode(param).then(res=>{   
                self.operatorData = res.content;
            });
    },    
    onSubmit(){
      let self = this;
      self.detailObj.status = 0;
      planApi.insertMpWx(self.detailObj).then(res=>{
         this.wxDialog.isShow = false;
         this.getTablList();
         this.$message({
          message: '修改成功',
          type: 'success'
        });
      })
    },
    planTask(type,row){
      let self = this;     
      self.processDetailId = row.processDetailId;
      switch (type) {
        case '1': break;
        case '2': break;
        case '3': self.statusDialog.isShow = true;break;
        case '4': self.updateRwqs();break;
        case '5': self.updateRwkg();break;
        case '6': self.updateRwwg();break;      
        default:
          break;
      }
      self.statusDialog.title  = "状态编辑";
      self.statusDialog.type = type;
    },
    getSelectedData(val){
      this.processDetailIds = val;
    },
    queryWorkerList(){
      let self = this;
      planApi.getWorkerList().then(res=>{
        self.workerList = res.content;
      });
    },
    getTablList(){/**计划列表 */
      let self = this;
      self.postData.drawCode=self.search.drawCode;
      self.postData.makeNo=self.search.makeNo;
      self.postData.code=self.search.code;
      self.postData.state= self.status;
      self.postData.name = self.nameType;
      self.postData.taskNo=self.search.taskNo;
      self.postData.customer=self.search.customer;
      self.postData.code29=self.search.code29;
      self.postData.taskSerialNo=self.search.taskSerialNo;
      debugger;
      self.postData.startDate=self.search.startDate?self.timestampToTime(self.search.startDate,'yyyy-mm-dd'):'';
      self.postData.endDate=self.search.endDate?self.timestampToTime(self.search.endDate,'yyyy-mm-dd') :'';
      self.postData.processDetailState=self.search.processDetailState?self.search.processDetailState:null;
      self.$refs.tableList29.get29TableList()
    },
    searchBtn(){
      this.getTablList();
    },
    /**重置数据 */
    reSearchBtn(){
      this.search.drawCode = '';
      this.search.makeNo = '';
      this.search.code = '';
      this.search.taskNo = '';
      this.search.customer = '';
      this.search.code29 = '';
      this.search.taskSerialNo = '';
      this.search.processDetailState = '';
      this.getTablList();
    },
    showDialog(type,row){
      this.dialog.activeName='7';
      this.dialog.type = type;
      switch(type){
        case 'insert':
          this.dialog.isShow=true;
          this.dialog.formData={};
          this.dialog.title = '新增计划任务';
          break;
        case 'update':
          this.dialog.isShow=true;
          this.dialog.formData = row;
          this.dialog.formData.isBobj = true;
          this.isChange = this.isChange?false:true;
          this.dialog.title = '计划详情';
          this.dialog.drawCode = row.drawCode;
          this.dialog.otherUpDataData.drawNo=row.drawCode;
          break;
        case 'imsertWx':
          this.wxDialog.isShow=true;
          this.wxDialog.formData = row;
          this.detailObj.totalId = row.id;
          this.detailObj.status = 0;
          this.wxDialog.title = '外协编辑';
          break;
      } 
    },
    showDialog1(type,row){
      this.dialog1.isShow=true;
      this.dialog1.type=type;
      switch(type){
        case 'insert':
          this.dialog1.formData={};
          this.dialog1.title = '新增29所工艺详情';
          break;
        case 'update':
          this.dialog1.formData = row;
          this.dialog1.title = '编辑29所工艺详情';
        break;
      }
    },
    /**详情切换tab*/ 
    dialogHandleClick(){
      let self = this;
      switch(self.dialog.activeName){
        case '1':
          this.isChange = this.isChange?false:true;
          break;
        case '2':
          self.$refs.processPlanList29Ref.getProcessPlanList();
          break;
        case '3':
          self.$refs.drawing.getTableList();
          break;
        case '4':
          self.$refs.technology.getTableList();
          break;
        case '5':
          self.$refs.graphicsFile.getTableList();
          break;
        case '6':
          self.$refs.processPlanListRef.getProcessPlanList();
          break;
        case '7':
          /**生产工序记录*/
          this.$refs.productionRecordListRef.getRecordList();
          break;
      }
    },
    /***确认编程完成 */
    confirmHandle(row){
      let self  = this;
       self.$confirm('是否确认编程完成?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          materielApi.finishProgram(row.id).then(res=>{
            self.$message.success("确认成功")
            self.getTablList();
          })
        }).catch(()=>{})
    },
    dialogOpened(){
      this.dialog.type==='update'? this.$refs.productionRecordListRef.getRecordList():'';
    },
    dialogClosed(){
      this.$refs.productionRecordListRef.getRecordList();
    },
    /**显示编程页面列表*/ 
    showProgramDialog(row){
      let self= this;
      self.programDialog.isShow = true;
      self.programDialog.title =`${row.nameName}详情`;
      self.programDialog.programObj = {
        data:row,
        tid:row.id,
        drawCode:row.drawNo,
        processId:row.name
      };
    },
    openedProgramDialog(){
      this.$refs.programDetail.getProgramList();
    }
  }
}
</script>
<style lang="stylus" scoped>
  .addRole
    padding-bottom 10px
  .content-rowspan div
    padding-left: 13px;
    line-height: 46px;
    border-bottom: 1px solid #ECEDEE;
    &:last-child
      border-bottom:none
</style>